<?php namespace Admin\Controller; 
use Hdphp\Controller\Controller;

class BrandController extends Controller{
	protected $tagModel;
	//构造函数
	public function __init()
	{
		//检测用户是否登陆
		//p($_SESSION['uid']);exit;
		if(!isset($_SESSION['aid'])) header('Location: '.U('Login/index'));
		$this->tagModel = new  \Common\Model\Brand;
	}
	
	
	public function index(){
		$brand = $this->tagModel->get();
		
		View::with('brand',$brand);
		View::make();
	}
	
	
	public function add(){
		
		if(IS_POST){
			
			if($this->tagModel->myadd()){
				View::success('添加成功',U('Brand/index'));
			}
			View::error($this->tagModel->getError());
		}
		
		View::make();
	}
	
	public function edit(){
		if(IS_POST){
			if($this->tagModel->myedit()){
				View::success('编辑成功');
			}
			View::error($this->tagModel->getError());
		}
		View::make();
	}
	
	
	public function del(){
		if($this->tagModel->delete(Q('get.tid')))
			View::success('删除标签成功',U('Tag/index'));
		View::error($this->tagModel->getError(),U('Tag/index'));
	}
}